<!DOCTYPE html>
<html>
<meta charset="utf-8">
<head th:include="include :: header"></head>
<body class="white-bg">
    <div class="wrapper wrapper-content animated fadeInRight ibox-content">
        <form class="form-horizontal m" id="form-${model.modelL}-add">
#foreach($field in $fieldList)
#if($field.isPk != "Y"&&${field.inputType}!="none")
#if(${field.inputType}=="date")
         <div class="form-group">	
		    <label class="col-sm-3 control-label">${field.comment}：</label>
			<div class="col-sm-8">
			    <div class="input-group"> <span class="input-group-addon"><i class="fa fa-calendar"></i></span>
			       <input type="text" id="${field.field}" name="${field.field}" class="form-control" value="" placeholder="yyyy-MM-dd"/>
			    </div>
			</div>
		</div>
#elseif(${field.inputType}=="time")
         <div class="form-group">	
		    <label class="col-sm-3 control-label">${field.comment}：</label>
			<div class="col-sm-8">
			    <div class="input-group"> <span class="input-group-addon"><i class="fa fa-calendar"></i></span>
			       <input type="text" id="${field.field}" name="${field.field}" class="form-control" value="" placeholder="HH:mm:ss"/>
			    </div>
			</div>
		</div>
#elseif(${field.inputType}=="datetime")
         <div class="form-group">	
		    <label class="col-sm-3 control-label">${field.comment}：</label>
			<div class="col-sm-8">
			    <div class="input-group"> <span class="input-group-addon"><i class="fa fa-calendar"></i></span>
			       <input type="text" id="${field.field}" name="${field.field}" class="form-control" value="" placeholder="yyyy-MM-dd HH:mm:ss"/>
			    </div>
			</div>
		</div>
#elseif(${field.inputType}=="htmleditor")
         <div class="form-group">	
		    <label class="col-sm-3 control-label">${field.comment}：</label>
			<div class="col-sm-8">
		       <script id="${field.field}" name="${field.field}" type="text/plain"> </script>
			</div>
		</div>
#elseif(${field.inputType}=="textarea")
         <div class="form-group">	
		    <label class="col-sm-3 control-label">${field.comment}：</label>
			<div class="col-sm-8">
				<textarea rows="6" cols=""  id="${field.field}" name="${field.field}" th:inline="text" class="form-control"></textarea>
			</div>
		</div>
#elseif(${field.inputType}=="select"&&${field.inputValueOne} == "sys_dept")
         <div class="form-group">	
		    <label class="col-sm-3 control-label">${field.comment}：</label>
			<div class="col-sm-8"> 
		       <input name="${field.field}"  type="hidden" id="treeId"/>
		       <input type="text" id="treeName" name="treeName" class="form-control" onclick="selectDeptTree()" readonly="true"/>
		    </div>
		</div> 
#elseif(${field.inputType}=="file")
         <div class="form-group">	
		    <label class="col-sm-3 control-label">${field.comment}：</label>
			<div class="col-sm-8"> 
		         <div class="container"> 
			        <div class="imageBox" id="${field.field}_imageBox"> 
				        <div class="thumbBox" id="${field.field}_thumbBox"></div> 
				        <div class="spinner" id="${field.field}_spinner" style="display: none">Loading...</div> 
				   </div> 
				   <div class="action"> 
				       <div class="new-contentarea tc">
				           <a href="javascript:void(0)" class="upload-img"> <label for="avatar">选择图片</label> </a> 
				           <input type="file" class="" id="${field.field}" accept="image/*"/>
				            <input type="hidden" name="${field.field}" id="${field.field}_name"/>
				       </div>  
					   <input type="button" id="${field.field}_btnZoomIn" class="Btnsty_peyton" value="+" /> 
					   <input type="button" id="${field.field}_btnZoomOut" class="Btnsty_peyton" value="-" /> 
					   <input type="button" id="${field.field}_blobSubmit" class="Btnsty_peyton" value="上传" /> 
				   </div>  
			    </div>
		    </div>
		</div> 
#elseif(${field.inputType}=="radio")
         <div class="form-group">	
		    <label class="col-sm-3 control-label">${field.comment}：</label>
			<div class="col-sm-8"> 
		      <div class="onoffswitch">
                         <input type="checkbox" th:checked="true" class="onoffswitch-checkbox" id="${field.field}" name="${field.field}"/>
                         <label class="onoffswitch-label" for="${field.field}">
                             <span class="onoffswitch-inner"></span>
                             <span class="onoffswitch-switch"></span>
                         </label>
              </div>
            </div>
		</div> 
#elseif(${field.inputType}=="select")
#if(${field.inputValueTwo} == "")
         <div class="form-group">	
		    <label class="col-sm-3 control-label">${field.comment}：</label>
			<div class="col-sm-8"> 
		      <select id="${field.field}" name="${field.field}" class="form-control m-b" th:with="type=${@dictService.selectDictData('${field.inputValue}')}">
                  <option value="">请选择</option>
                   <option th:each="dict : ${type}" th:text="${dict['dictLabel']}" th:value="${dict['dictValue']}"></option>
               </select>
            </div>
		</div> 
#elseif(${field.inputValueTwo} != "")
         <div class="form-group">	
		    <label class="col-sm-3 control-label">${field.comment}：</label>
			<div class="col-sm-8"> 
		      <select id="${field.field}" name="${field.field}" class="form-control m-b" th:with="type=${ @${field.inputValueOneL}ServiceImpl.selectAll()}">
                  <option value="">请选择</option>
                   <option th:each="dict : ${type}" th:text="${ dict.${field.inputValueTwo}}" th:value="${dict.id}"></option>
               </select>
            </div>
		</div> 
#end
#elseif(${field.inputType}=="checkbox")
#if(${field.inputValueTwo} == "")
         <div class="form-group">	
		    <label class="col-sm-3 control-label">${field.comment}：</label>
			<div class="col-sm-8"> 
		     <label th:each="dict:${@dictService.selectDictData('${field.inputValue}')}" class="checkbox-inline i-checks" >
				<input name="${field.field}" type="checkbox" th:value="${dict['dictValue']}" th:text="${dict['dictLabel']}"/>
			</label>
            </div>
		</div> 
#end
#else
        <div class="form-group">	
            <label class="col-sm-3 control-label">${field.comment}：</label>
            <div class="col-sm-8">
                <input id="${field.field}" name="${field.field}" class="form-control" type="text" placeholder="请输入${field.comment}"/>
            </div>
        </div>
#end
#end
#end
       <div class="form-group">
		<div class="form-control-static col-sm-offset-9">
			<button type="submit" class="btn btn-primary">提交</button>
			<button th:onclick="'javascript:layer_close()'" class="btn btn-danger" type="button">关闭</button>
            </div>
        </div>
    </form>
    </div>

    <div th:include="include::footer"></div>
    
<script type="text/javascript" th:inline="javascript">
	layui.use('laydate', function(){
	  var laydate = layui.laydate;
#foreach($field in $fieldList)
#if(${field.inputType}=="datetime")
  //日期时间选择器
  laydate.render({
    elem: '#${field.field}'
    ,type: 'datetime'
  });
#elseif(${field.inputType}=="date")
  laydate.render({
    elem: '#${field.field}'
  });
#elseif(${field.inputType}=="time")
  laydate.render({
    elem: '#${field.field}'
    ,type: 'time'
  });
#end
#end	  
	   });


#foreach($field in $fieldList)
#if(${field.inputType}=="file")
	  $(window).load(function() {
	    var ${field.field}_options = {
	        thumbBox: '#${field.field}_thumbBox',
	        spinner: '#${field.field}_spinner',
	        //imgSrc: '/img/profile.jpg'
	    }
	    var cropper = $('#${field.field}_imageBox').cropbox(${field.field}_options);
	    $('#${field.field}').on('change',
	    function() {
	        var reader = new FileReader();
	        reader.onload = function(e) {
	            ${field.field}_options.imgSrc = e.target.result;
	            //根据MIME判断上传的文件是不是图片类型
	            if((${field.field}_options.imgSrc).indexOf("image/")==-1){
	                parent.layer.alert("文件格式错误，请上传图片类型,如：JPG,JEPG，PNG后缀的文件。", {icon: 2,title:"系统提示"});
	            } else {
	                cropper = $('#${field.field}_imageBox').cropbox(${field.field}_options);
	            }
	        }
	        reader.readAsDataURL(this.files[0]);
	    })
	    $('#${field.field}_blobSubmit').on('click', function(){
	        var img = cropper.getBlob();
	        var formdata = new FormData();
	        formdata.append("avatarfile", img);
	       // formdata.append("userId", $("#userId").val());
	        $.ajax({
	            url: ctx + "file/uploadImg",
	            data: formdata,
	            type: "post",
	            processData: false,
	            contentType: false,
	            success: function(result) {
	            	if (result.code == "0") {
	            		parent.layer.msg("修改成功,正在刷新数据请稍后……",{icon:1,time: 500,shade: [0.1,'#fff']},function(){
	            			$("#${field.field}_name").val(result.avatar);
	            		});
	                }else{
	                	$.modalAlert(result.msg, "error");
	                }
	            }
	        })
	    }) 
		$('#${field.field}_btnZoomIn').on('click', function(){
			cropper.zoomIn();
		})
		$('#${field.field}_btnZoomOut').on('click', function(){
			cropper.zoomOut();
		})
	});

#elseif(${field.inputType}=="htmleditor")
	var ue_${field.field} = UE.getEditor('${field.field}');
#end
#end 
</script> 
    <script src="/jee/${model.modulePackage}/${model.modelL}/add.js" th:src="@{/jee/${model.modulePackage}/${model.modelL}/add.js}">
    </script>
</body>
</html>
